<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Vue实例生命周期函数</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
    <div id="app">
        hello world
    </div>
</body>
<script>
    var vm = new Vue({
        el: "#app",
        data: {
            test: "hello world"
        },
        // vue 实例注册初始化执行
        beforeCreate: function() {
            console.log("beforeCreate");

        },
        created: function() {
            console.log("create");

        },
        beforeMount: function() {
            console.log(this.$el);
            console.log("beforeMount")
        },

        // 页面被渲染完毕
        mounted: function() {
            console.log(this.$el);
            console.log("mounted")
        },

        // 控制台调用
        beforeDestroy: function() {
            console.log("beforeDestroy")
        },
        destroyed: function() {
            console.log("destroyed")
        },

        // 数据改变开始执行
        beforeUpdate: function() {
            console.log("beforeUpdate")
        },
        updated: function() {
            console.log("updated")
        }
    })
</script>

</html>